package com.gxg.kotlin.mydemo10.adapter;

import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.gxg.kotlin.mydemo10.R;
import com.gxg.kotlin.mydemo10.bean.TopBean;

import java.util.List;

/**
 * 作者：Administrator on 2018/2/9 15:27
 * 邮箱：android_gaoxuge@163.com
 */
public class HomeAdapter extends BaseQuickAdapter<TopBean.SubjectsBean,BaseViewHolder> {
    String username;
    public HomeAdapter(@Nullable List<TopBean.SubjectsBean> data) {
        super(R.layout.item_home,data);
    }

    @Override
    protected void convert(BaseViewHolder helper, TopBean.SubjectsBean item) {
        ImageView iv_left = helper.getView(R.id.iv_left);
        Glide.with(mContext).load(item.getImages().getLarge()).into(iv_left);

        helper.setText(R.id.tv_title,item.getTitle());
        helper.setText(R.id.tv_pingfen,"评分："+item.getRating().getAverage()+"");

        helper.setText(R.id.tv_daoyan,item.getDirectors().get(0).getName());
        username = "";
        for (TopBean.SubjectsBean.CastsBean castsBean : item.getCasts()) {
            if(!TextUtils.isEmpty(castsBean.getName())){
                username+=castsBean.getName()+"  ";
            }
        }
        helper.setText(R.id.tv_zhuyan,username);
    }
}
